package com.zonda.sampleretrofit2.model;


import android.text.TextUtils;
import android.util.JsonReader;

import java.io.IOException;

public class AppBasicResult extends AppBasicObject {

  private String stat;

  private String msg;

  @Override
  public final boolean convertFrom(JsonReader jsonReader) throws IOException {
    super.convertFrom(jsonReader);
    try {
      jsonReader.beginObject();
      while (jsonReader.hasNext()) {
        final String name = jsonReader.nextName();
        if (TextUtils.equals(name, "stat")) {
          stat = jsonReader.nextString();
        } else if (TextUtils.equals(name, "msg")) {
          msg = jsonReader.nextString();
        } else if (TextUtils.equals(name, "data")) {
          final boolean isSuccessRead = readDataObject(jsonReader);
          if (!isSuccessRead) {
            jsonReader.skipValue();
          }
        } else {
          jsonReader.skipValue();
        }
      }
      jsonReader.endObject();
      return true;
    } finally {
      jsonReader.close();
    }
  }

  protected boolean readDataObject(JsonReader jsonReader) throws IOException {
    return false;
  }

  public String getStat() {
    return stat;
  }

  public void setStat(String stat) {
    this.stat = stat;
  }

  public String getMsg() {
    return msg;
  }

  public void setMsg(String msg) {
    this.msg = msg;
  }
}
